package com.example.administrator.shzs.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.administrator.shzs.activity.BaseActivity;
import com.example.administrator.shzs.app.MyApplication;
import com.example.administrator.shzs.R;
import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 备注界面
 */
public class RemarkActivity extends BaseActivity implements View.OnClickListener{


    @Bind(R.id.iv_back)
    ImageView ivBack;//返回键
    @Bind(R.id.et_remark)
    EditText etRemark;
    @Bind(R.id.tv_not_eat_peppery)
    TextView tvNotEatPeppery;
    @Bind(R.id.tv_less_put_pepper)
    TextView tvLessPutPepper;
    @Bind(R.id.tv_much_put_pepper)
    TextView tvMuchPutPepper;
    @Bind(R.id.tv_not_eat_garlic)
    TextView tvNotEatGarlic;
    @Bind(R.id.tv_not_eat_caraway)
    TextView tvNotEatCaraway;
    @Bind(R.id.tv_not_eat_scallion)
    TextView tvNotEatScallion;
    @Bind(R.id.btn_remark)
    Button btnRemark;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_remark);
        ButterKnife.bind(this);
        MyApplication.app.activityList.add(this);

        setListeners();
    }

    private void setListeners() {


        tvLessPutPepper.setOnClickListener(this);
        tvMuchPutPepper.setOnClickListener(this);
        tvNotEatGarlic.setOnClickListener(this);
        tvNotEatCaraway.setOnClickListener(this);
        tvNotEatScallion.setOnClickListener(this);
        tvNotEatPeppery.setOnClickListener(this);
        btnRemark.setOnClickListener(this);
        ivBack.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {

        String s="";
        switch (v.getId()){

            case R.id.tv_not_eat_peppery://不吃辣

                s=tvNotEatPeppery.getText().toString();
                etRemark.append(s);
                break;

            case R.id.tv_less_put_pepper://少放辣

                s=tvLessPutPepper.getText().toString()+"  ";
                etRemark.append(s);
                break;

            case R.id.tv_much_put_pepper://多放辣

                s=tvMuchPutPepper.getText().toString()+"  ";
                etRemark.append(s);
                break;

            case R.id.tv_not_eat_garlic://不吃蒜

                s=tvNotEatGarlic.getText().toString()+"  ";
                etRemark.append(s);
                break;

            case R.id.tv_not_eat_caraway://不吃香菜

                s=tvNotEatCaraway.getText().toString()+"  ";
                etRemark.append(s);
                break;

            case R.id.tv_not_eat_scallion://不吃葱

                s=tvNotEatScallion.getText().toString()+"  ";
                etRemark.append(s);
                break;

            case R.id.btn_remark:

                String remark=etRemark.getText().toString();
                if(remark.equals("")){
                    finish();
                }else {
                    Intent intent = getIntent();
                    intent.putExtra("remark",remark);
                    setResult(RESULT_OK,intent);
                    finish();
                }

                break;

            case R.id.iv_back:

                finish();
                break;
        }



    }
}
